<template>
    <div>
        <el-container>
            <el-header>
                <el-row :gutter="20">
                    <el-col :span="20">
                        <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect"
                            background-color="#545c64" text-color="#fff" active-text-color="#ffd04b">
                            <el-menu-item index="1">
                                <router-link to="/employee">订单处理中心</router-link>
                            </el-menu-item>
                            <el-submenu index="2">
                                <template slot="title">个人中心</template>
                                <el-menu-item index="2-1">
                                    <router-link to="/employee/shippedOrder">正在配送订单</router-link>
                                </el-menu-item>
                                <el-menu-item index="2-2">
                                    <router-link to="/employee/dispatchedOrder">已配送订单</router-link>
                                </el-menu-item>
                                <el-menu-item index="2-3">
                                    <router-link to="/employee/ownInfo">个人信息</router-link>
                                </el-menu-item>
                            </el-submenu>
                            <el-menu-item index="3"><router-link to="/employee/messageCenter">消息中心</router-link></el-menu-item>
                            <el-menu-item index="4">设置</el-menu-item>
                        </el-menu>
                    </el-col>
                    <el-col :span="4">
                        <span style="color:white;" v-if="JSON.stringify(employeeInfo) == '{}' " @click="toLogin">未登录？请及时登录</span>
                        <span style="color:white;" v-if="JSON.stringify(employeeInfo) != '{}'">{{employeeInfo.username}}</span>
                    </el-col>
                </el-row>
            </el-header>
            <el-main style="min-height:800px">
                <router-view :employeeId="employeeInfo.id"></router-view>
            </el-main>
        </el-container>
    </div>
</template>
<script>
import {getEmployeeBaseInfo} from '@/utils/modules/employee.js'
export default {
    mounted(){
        this.init()
    },
    data() {
        return {
            activeIndex: '1',
            employeeInfo:{

            }
        };
    },
    methods: {
        handleSelect(key, keyPath) {
            console.log(key, keyPath);
        },
        init(){
            getEmployeeBaseInfo().then(res=>{
                this.employeeInfo = res.data
                console.log(this.employeeInfo)
            }).catch(err=>{
                this.$message({
                    type:'error',
                    message:err.message,
                    showClose:true
                })
            })
        },
        toLogin(){
            this.$router.push({
                path:'/login'
            })
        }
    }
}
</script>
<style>
.el-header {
    background-color: rgb(84, 92, 100);
    color: #333;
    text-align: center;
    line-height: 60px;
}

.el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    line-height: 160px;
}

a {
    text-decoration: none;
}

.router-link-active {
    text-decoration: none;
}
</style>